package com.rjj.wlqq.wx.common.config;

import com.rjj.wlqq.wx.common.core.ApiConfig;
import com.rjj.wlqq.wx.common.core.ApiConfigKit;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author r
 * @date 2020/12/26 21:13
 * 把appId 和 appSecret 放到map中存起来使用
 */
@Configuration
public class WxConfig
{
    @Value("${wx.appId}")
    private String appId;
    @Value("${wx.appSecret}")
    private String appSecret;
    @Value("${wx.token}")
    private String token;

    @PostConstruct
    public void init(){
        final ApiConfig apiConfig = new ApiConfig();
        apiConfig.setAppId(appId);
        apiConfig.setAppSecret(appSecret);
        apiConfig.setToken(token);
        ApiConfigKit.putApiConfig(apiConfig);
        ApiConfigKit.setThreadLocalAppId(appId);
    }

}
